﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Facebook.Json;

namespace Facebook
{
    public class JsonResponse<TOriginalValue>
    {
        internal JsonResponse() { }

        public JsonResponse(FacebookResponse<TOriginalValue> response)
        {
            this.InnerResponse = response;
            if (!this.InnerResponse.IsError) this.Value = JsonConvert.SerializeObject(this.InnerResponse.Value);
        }

        private FacebookResponse<TOriginalValue> InnerResponse { get; set; }

        #region [ IFacebookResponse Members ]

        public void Init(String content)
        {
            this.InnerResponse.Init(content);
            if(!this.InnerResponse.IsError) this.Value = JsonConvert.SerializeObject(this.InnerResponse.Value);
        }

        public Exception ResponseException
        {
            get { return this.InnerResponse.ResponseException; }
        }

        public Boolean IsError
        {
            get { return this.InnerResponse.IsError; }
        }

        #endregion

        public String Value { get; private set; }
    }
}
